package com.aierjun.ani.utils;

import android.app.Activity;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;

/**
 * Created by Ani_aierJun on 2017/10/19.
 */

/*
* 软键盘工具类
*
* */
public class SoftInputFromWindow {

    private void hideSoftInputFromWindow(Activity activity) {
        InputMethodManager imm = ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE));
        if (imm != null) {
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

    private void showSoftInputFromWindow(Activity activity) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            activity.getCurrentFocus().requestFocus();
            imm.showSoftInput(activity.getCurrentFocus(), 0);
        }
    }

}
